#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int ss(int a, int b)
{
    int count = 0;
    while (a)
    {
        if (a % 10 == b)
        {
            count++;
        }
        a = a / 10;
    }
    int j = 0;
    for (int i = 0; i < count; i++)
    {
        j = j * 10 + b;
    }
    return j;
}
int main()
{
    int M, m;
    int N, n;
    scanf("%d%d", &M, &m);
    scanf("%d%d", &N, &n);
    int x = ss(M, m);
    int y = ss(N, n);
    int sum = x + y;
    printf("%d", sum);
    return 0;
}